<template>
  <div>
    <Parent :parentDepth="parentDepth - 1" :parentData="parentData.parent" @parentCallReply="diguiCallReply" v-if="parentData.parent" />
    <div class="parentComment">
      <div class="info">
        <div class="user">
          {{ parentDepth }}{{ parentData.user.nickname }}
          {{ parentData.user.create_date.split('T')[0] }}
        </div>
        <div class="btnReply" @click="parentCallReply">
          回复
        </div>
      </div>
      <div class="content">
        {{ parentData.content }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Parent',
  props: ['parentData', 'parentDepth'],
  methods: {
    parentCallReply() {
      this.$emit('parentCallReply', {
        id: this.parentData.id,
        nickname: this.parentData.user.nickname
      })
    },
    diguiCallReply(parentInfo) {
      this.$emit('parentCallReply', parentInfo)
    }
  }
}
</script>

<style lang="less" scoped>
.parentComment {
  font-size: 3.8889vw;
  color: #888;
  padding: 2.7778vw;
  border: 1px solid #e4e4e4;
}
.info {
  display: flex;
  justify-content: space-between;
  .btnReply {
    font-size: 3.3333vw;
  }
}
.content {
  padding: 2.7778vw 0;
}
</style>
